var toast = {
	init:function(){
		var html = "<div class='toast'><div class='toastInner'></div></div>";
		$('body').append(html);
	},	
	show:function(msg){
		$('.toast .toastInner').html(msg);
		$('.toast').fadeIn(500);
		var timer = setTimeout(function(){
			$('.toast').fadeOut(500);
			clearTimeout(timer);
		},2000)
	}
}
toast.init();
//toast提示框


var loading = {
	init:function(){
		var html = "<div class='loading'></div>";
		$('body').append(html);
	},	
	show:function(){
		$('.loading').fadeIn(500);
	},
	hide:function(){
		$('.loading').fadeOut(500);
	}
}
loading.init();
//加载中


var getModal = {
	def:{
	  title:"提示",
	  content:"确定取消么？",
	  type:"2",
	  cb_l:"",//左按钮回调
	  cb_r:"",//右按钮回调
	  btnTxt1:"确定",
	  btnTxt2:"取消"
	},
	init:function(object){
	  if(object.type==1){
	    var html = '<div class="myModal"><div class="modal-mask"></div><div class="modal-dia"><div class="modal-inner"><div class="modal-hd">'+ object.title +'<a href="javascript:;" class="close btnClose"></a></div><div class="modal-body">'+ object.content +'</div><div class="modal-foot"><a href="javascript:;" class="myModalBtnComfirm">'+ object.btnTxt1 +'</a></div></div></div></div>'
	    $('body').append(html);
	  }else if(object.type==2){
	    var html = '<div class="myModal"><div class="modal-mask"></div><div class="modal-dia"><div class="modal-inner"><div class="modal-hd">'+ object.title +'<a href="javascript:;" class="close btnClose"></a></div><div class="modal-bd"><p>'+ object.content +'</p></div><div class="modal-foot"><a href="javascript:;" class="first myModalBtnComfirm">'+ object.btnTxt1 +'</a><a href="javascript:;" class="myModalBtnClose">'+ object.btnTxt2 +'</a></div></div></div></div>'
	    $('body').append(html);
	  }
	},
	show:function(param){
	  var object = this.def = $.extend({}, this.def, param);
	
	  this.init(object);
	  $('.myModal').fadeIn(300);
	  this.close();
	},
	close:function(){
	  var _self = this;
	  $(".myModalBtnComfirm").on('click',function(){
	    $('.myModal').remove();
	    if (typeof _self.def.cb_l === "function"){
	        _self.def.cb_l();
	    }
	  })
	
	  $(".myModalBtnClose").on('click',function(){
	    $('.myModal').remove();
	    if (typeof _self.def.cb_r === "function"){
            _self.def.cb_r();
        }
      })
      
      $(".btnClose").on('click',function(){
	    $('.myModal').remove();
      })
    }
  }
//自定义对话框

function cancel(value1) {
  
    document.getElementById(value1).style.display = 'none';
   
}

function loadApiGroup(){
	$.ajax({
		url:'/api/getAllGroups',
		type:'GET',
	}).done(function(res){
		if(res.success){
			var result = eval("("+res.value+")");
			var length = result.length;
			var html = "";
			for(var i=0,j=length;i<j;i++){
				html += '<option value='+result[i].id+'>'+result[i].name+'</option>';
			}
			//console.log(html);
			$("#groupId").html(html);
			
		}else{
			toast.show(res.errorMsg);
		}
	}).fail(function(res){
		toast.show(res.errorMsg);
	})
}

function serviceDiv(){
	var type=document.getElementById("serviceType").value;
	if('03'==type){
		  document.getElementById('dubboDiv').style.display = 'block';
		  document.getElementById('httpDiv').style.display = 'none';
	}else{
		 document.getElementById('dubboDiv').style.display = 'none';
		 document.getElementById('httpDiv').style.display = 'block';
	}
	
}
function show(value1) {
    document.getElementById(value1).style.display = 'block';
}